output {
  if [index_name] {
    elasticsearch {
      hosts => ["ingest.elastic.service.{{ consul_dc_name }}.consul:{{ elastic_http_port }}"]
      index => "%{[index_name]}-%{+YYYY.MM.dd}"
      {% if searchguard_enabled %}{{ logstash_ssl_output }}{% endif -%}
    }
  } else if [@metadata][beat] {
    elasticsearch {
      hosts => ["ingest.elastic.service.{{ consul_dc_name }}.consul:{{ elastic_http_port }}"]
      index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
      manage_template => false
      {% if searchguard_enabled -%}{{ logstash_ssl_output }}{% endif -%}
    }
  } else {
    elasticsearch {
      hosts => ["ingest.elastic.service.{{ consul_dc_name }}.consul:{{ elastic_http_port }}"]
      index => "logstash-%{+YYYY.MM.dd}"
      manage_template => true
      {% if searchguard_enabled %}{{ logstash_ssl_output }}{% endif -%}
    }
  }
}
